package org.lab.tracecash.io.bankia;

import java.text.SimpleDateFormat;

import net.sf.flatpack.DataSet;

import org.apache.commons.lang.StringUtils;
import org.lab.tracecash.io.BaseCsvImporter;

public class BankiaCsvImporter extends BaseCsvImporter {

	@Override
	public String getName() {
		return "Bankia CSV";
	}

	@Override
	protected SimpleDateFormat getDateFormat() {
		return new SimpleDateFormat("yyyy-MM-dd");
	}

	@Override
	protected String getColumnValueDate() {
		return "Fecha";
	}

	@Override
	protected String getColumnAmount() {
		return "Importe";
	}

	@Override
	protected String getColumnDesc() {
		return "Descripción";
	}

	@Override
	protected String getLongDesc(DataSet ds) {
		StringBuffer sb = new StringBuffer();
		for (int i = 1; i < 7; i++) {
			String value = ds.getString("Concepto " + i);
			if (StringUtils.isNotBlank(value)) {
				sb.append(value).append("|");
			}
		}
		return sb.toString();
	}
}
